/********************************************************************************
  DESCRIPTION OF THE FILE HERE
********************************************************************************/

#include "client.h"
#include "common.h"

typedef struct SClient {  
  ptrRequest request; /* la richiesta che metteremo sulla porta */
} Client;

static void Client_init(ptrClient client, ptrRequest request){
  client->request = request;
}

ptrClient Client_create(ptrRequest request){
  ptrClient client = new(Client);
  Client_init(client, request);
  return client;
}

ptrResponse Client_sendRequest(ptrClient client){
  ptrResponse res;
  debug("I'M GONNA POST MY REQUEST ONTO THE PORT NOW!\n");
  res = Port_putRequestRPC(client->request);
  debug("I GOT THE RESULT FROM THE SERVER:\n\t");
#ifdef DEBUG
  Response_printf(res);
#endif
  return res;
}

#ifdef DEBUG
void Client_printf (ptrClient client){
  /* BLA, BLA, BLA */
}
#endif /* DEBUG */

static void Client_deinit(ptrClient client){
  /* do nothing */
};

void Client_destroy(ptrClient client){
  if (client != NULL){
    Client_deinit(client);
    delete(client);
  }
}
